﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.Text;
using DomainDriver.DomainModeling.DomainObjects;
using DomainDriver.DomainModeling.StorageManagers.DataSetStorage;
using ObjectRow = AutomotivePricingModel.ValueObjects.YearlyFinancialAssessments.YearlyFinancialAssessmentsDataSet.YearValueObservationsRow;

namespace AutomotivePricingModel.ValueObjects.YearlyFinancialAssessments
{
    public partial class YearValueObservation
    {
        #region AutomotivePricingDataSet Serialization

        private string ObjectTableName
        {
            get { return YearlyFinancialAssessmentsDataSet.SchemaHelper.YearValueObservations.TableName; }
        }

        private string YearColumnName
        {
            get { return YearlyFinancialAssessmentsDataSet.SchemaHelper.YearValueObservations.YearColumn.ColumnName; }
        }

        private string ParentIdColumnName
        {
            get { return YearlyFinancialAssessmentsDataSet.SchemaHelper.YearValueObservations.ParentIdColumn.ColumnName; }
        }

        private string ValueColumnName
        {
            get { return YearlyFinancialAssessmentsDataSet.SchemaHelper.YearValueObservations.ValueColumn.ColumnName; }
        }

        public void Serialize(DataSet dataSet, DataRow dataRow)
        {
            dataRow[YearColumnName] = m_Year;
            dataRow[ParentIdColumnName] = m_ParentYearlyFinancialAssessmentId;
            dataRow[ValueColumnName] = m_Value;
            dataSet.Tables[ObjectTableName].Rows.Add(dataRow);
        }

        public void Deserialize(DataSet dataSet, DataRow dataRow)
        {
            m_Value = (double)dataRow[ValueColumnName];
            m_Year = (int)dataRow[YearColumnName];
            m_ParentYearlyFinancialAssessmentId = (Guid)dataRow[ParentIdColumnName];
        }

        #endregion
    }
}